package com.dmtt.web.controller;

import com.dmtt.util.R;
import com.dmtt.web.entity.*;
import com.dmtt.web.service.ActivationService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/activation")
public class ActivationController {
    @Autowired
    private ActivationService activationService;

    //AGC稼动状况一览图图表
    @RequestMapping("/activa")
    public R activation(@RequestBody ActivationVo activationVo){
         List<Activation> list=activationService.activation(activationVo.getPage(), activationVo.getStartTime(), activationVo.getEndTime(), activationVo.getAgvName());
         return R.ok().put("a",list);
    }
    //AGC稼动状况一览图图表导出
//    @RequestMapping("/activaExport")
//    public ResponseEntity<byte[]> activaExport(@RequestBody ActivationVo activationVo){
//        return activationService.activaExport(activationVo.getPage(), activationVo.getStartTime(), activationVo.getEndTime(), activationVo.getAgvName());
//    }

    //AGC故障率
    @RequestMapping("/faultAccumulation")
    public R faultAccumulation(@RequestBody ActivationVo activationVo){
        List<Activation> faultAccumulation = activationService.faultAccumulation(activationVo);
        return R.ok().put("faultAccumulation",faultAccumulation);
    }
//    //AGC故障率导出
//    @RequestMapping("/faultAccumulationExport")
//    public ResponseEntity<byte[]> faultAccumulationExport(@RequestBody ActivationVo activationVo){
//        return activationService.faultAccumulationExport(activationVo);
//    }

//    AGC故障率推移图
//    @RequestMapping("/faultPassing")
//    public R faultPassing(ActivationVo activationVo){
//        List<Activation> faultPassing = activationService.faultPassing(activationVo);
//        return R.ok().put("faultPassing",faultPassing);
//    }
//    //AGC故障率推移图导出
//    @RequestMapping("/faultPassingExport")
//    public ResponseEntity<byte[]> faultPassingExport(ActivationVo activationVo){
//        return activationService.faultPassingExport(activationVo);
//    }

    //稼动率分析图表
    @RequestMapping("/movementRate")
    public R movementRate(@RequestBody ActivationVo activationVo){
        List<MovemontRate> list =  activationService.movementRate(activationVo);
        return R.ok().put("movementRate",list);
    }

//    //稼动率分析图表
//    @RequestMapping("movementRateExport")
//    public ResponseEntity<byte[]> movementRateExport(@RequestBody ActivationVo activationVo){
//        return activationService.movementRateExport(activationVo);
//    }

    //AGC稼动状况推移图表
    @RequestMapping("/changeGrain")
    public R changeGrain(@RequestBody ActivationVo activationVo){
        List<ChangeGrain> list=activationService.changeGrain(activationVo.getPage(), activationVo.getStartTime(), activationVo.getEndTime(), activationVo.getAgvName());
        return R.ok().put("a",list);
    }
//    //AGC稼动状况推移图表导出
//    @RequestMapping("/changeGrainExport")
//    public ResponseEntity<byte[]> changeGrainExport(@RequestBody ActivationVo activationVo){
//        return activationService.changeGrainExport(activationVo.getPage(), activationVo.getStartTime(), activationVo.getEndTime(), activationVo.getAgvName());
//    }

    //AGC导出列表
    @RequestMapping("/agcStatisticsList")
    public R agcStatisticsList(@RequestBody ActivationVo activationVo){
        PageInfo<AgcStatistics> agcStatisticsList = activationService.AgcStatistic(activationVo.getStartTime(),activationVo.getEndTime(),activationVo.getAgvName(),activationVo.getCurrPage());
        return R.ok().put("agcStatisticsList",agcStatisticsList);
    }

    //AGC统计导出
    @RequestMapping("/agcStatisticsExport")
    public ResponseEntity<byte[]> agcStatisticsExport(@RequestBody ActivationVo activationVo){
        return activationService.agcStatisticsExport(activationVo.getStartTime(), activationVo.getEndTime(), activationVo.getAgvName());
    }

    //AGC平均稼动率导出
    @RequestMapping("/agcAverageExport")
    @ResponseBody
    public ResponseEntity<byte[]> agcAverageExport(){
        ActivationVo activationVo = new ActivationVo();
        activationVo.setPage("2");
        return activationService.agcAverageExport(activationVo.getPage(),activationVo.getStartTime(),activationVo.getEndTime(),activationVo.getAgvName());
    }

    //车辆列表下拉
    @RequestMapping("/carList")
    public R carList(){
        List<AgvList> car = activationService.carList();
        return R.ok().put("carList",car);
    }

    //年历添加接口
    @RequestMapping("/yearCalendar")
    public R yearCalendar(@RequestBody ActivationVo activationVo){
        List<String> a = activationService.yearCalendar(activationVo);
        return R.ok().put("list",a);
    }

    //年历查询接口
    @RequestMapping("/yearCalendarQuery")
    public R yearCalendarQuery(){
        return R.ok().put("list",activationService.yearCalendarQuery());
    }
}
